﻿/* run pretty */
$(function () {
    $('.pretty').each(function () {
        var $container = $(this);
        var type = $container.data('type'),
            code = $container.data('code')
        $.ajax({
            url: '/Code/' + type + '/' + code,
            success: function (data) {
                var text = $('<div />').text(data).html();
                var prHtml = PR.prettyPrintOne(text, type, true);

                $container.addClass(type)
                    .html([
                        '<div class="ribbon" data-help="click here to view this code!"></div>',
                        '<div class="scroller code">',
                            '<pre class="prettyprint linenums">',
                                prHtml,
                            '</pre>',
                        '</div>'
                    ].join(''))
                    .find('.ribbon').on('click', function () {
                        $.dialog({
                            title: code,
                            content: 'url:/Content/' + code.replace(/-/g, '/') + '.' + type
                        }).max();
                    });
            }
        });
    });
});